==============================================================================
Replication Package for:
"Estimating Intergenerational Returns to Medical Care:
 New Evidence from At-Risk Newborns"

Damian Clarke, Nicolas Lillo Bustos, Kathya Tapia-Schythe

This replication package accompanies a paper conditionally accepted at the
Journal of Public Economics.
==============================================================================


1. OVERVIEW

This replication package reproduces all tables and figures reported in the
main text and appendix of the paper "Estimating Intergenerational Returns to
Medical Care: New Evidence from At-Risk Newborns".

The package includes Stata do-files for data preparation and estimation, as
well as a Python script to reproduce Figure 8. All final outputs are written
directly to the figures and tables directories.  For a precise mapping of
all figures and tables to the versions in the published paper, refer to the
latex file intergen_JPubE.tex at the top level of the replication materials.


2. DATA AVAILABILITY AND PROVENANCE

Raw data:
- Raw data are available as published by Chile's Ministry of Health (birth
records, hospitalisation records, and death records).  All files were 
anonymysed by the Ministry of Health prior to publication on the web at
deis.minsal.cl.  We provide an aggregated individual-level file.  Full 
details on the construction of this file are noted below.

Data setup:
- The construction and preparation of working datasets is documented in the
  folder source/Make workingdata.
- No manual data manipulation is required outside the provided scripts.


3. COMPUTATIONAL REQUIREMENTS

3.1 Operating Systems and Hardware

These materials have been confirmed to run under the following environment:

Computational setup 2 (interactive mode):
- Operating System: Windows 10 Pro
- CPU: Intel Core i7
- RAM: 48 GB
- Software: Stata-SE 15.1


3.2 Software Requirements

Stata:
- Stata-SE 15.1 

Python:
- Python version: 3.10.12
- Required libraries: Pandas 2.3.3, matplotlib 3.10.7


3.3 Required Stata Packages

The following user-written Stata packages are required and can be installed from the SSC:

- estout
- reghdfe
- require
- ftools
- rdbwselect
- rdplot
- rdrobust
- binsreg
- blindschemes
- lean2
- schemepack
- swindex

Additionally, the ado qsharpenedp is provided with the replication package

Finally, the following package must be installed from GitHub:

  net install rdpower, from(https://raw.githubusercontent.com/rdpackages/
  rdpower/master/stata) replace

All packages should be installed prior to running the replication scripts.


4. DIRECTORY STRUCTURE

The replication package is organized as follows:

.
├── data/
│   └── Contains all required data
├── source/
│   ├── IntergenReplication.do
│   ├── AppendixReplication.do
│   ├── SelectionReplication.do
│   ├── qsharpenedp.ado
│   ├── Make workingdata/
│   │   └── (scripts documenting data construction and preparation)
│   └── Figure8/
│       └── selectionBounds.py
├── log/
│   └── (log files generated by Stata scripts)
├── results/
│   └── (intermediate model outputs saved by estimation scripts)
├── tables/
│   └── (final tables reported in the paper)
├── figures/
│   └── (final figures reported in the paper)
├── intergen_JPubE.tex
├── refs.bib
└── README.txt


5. INSTRUCTIONS TO REPLICATE RESULTS

5.1 Setting the Working Directory

All Stata do-files rely on a single global directory definition. Before
running any scripts, users must edit the global "maindir" in the following
files:

- source/IntergenReplication.do (line 28)
- source/AppendixReplication.do (line 29)
- source/SelectionReplication.do (line 26)

No other modifications are required.  


5.2 Main Results (Paper)

To reproduce all tables and figures reported in the main text, run:

  source/IntergenReplication.do

This script:
- Calls the data preparation routines documented in source/Make workingdata
- Estimates all models reported in the main text
- Saves intermediate model outputs to the results directory
- Writes final tables and figures directly to the tables and figures
  directories

Expected running time:
- Windows (Stata-SE): approximately 3.5 hours

This script calls:
- source/SelectionReplication.do


5.3 Appendix Results

To reproduce all appendix tables and figures, run:

  source/AppendixReplication.do

This script:
- Uses the same data construction routines as the main replication
- Saves intermediate outputs to the results directory
- Writes final appendix tables and figures to the tables and figures
  directories

Expected running time:
- Windows (Stata-SE): approximately 6.5 hours


5.4 Selection Analysis

The following script constructs the datasets required for the selection
analysis used in the paper:

  source/SelectionReplication.do


5.5 Figure 8 (Python)

Figure 8 is reproduced using the following Python script:

  source/Figure8/selectionBounds.py

Before running, modify the working directory in line 7 if necessary.

Expected running time: <1 minute.


5.6 Compiling full results
If you wish to compile full results, you can simply compile the latex folder in
the main directory.  This can be compiled using xelatex and bibtex as follows:
xelatex intergen_JPubE; bibtex intergen_JPubE; bibtex appendix; xelatex intergen_JPubE; xelatex intergen_JPubE


6. OUTPUT FILES

All final outputs are written directly to the tables and figures
directories. File names correspond to the table and figure numbers in the
paper.

Intermediate estimation results are stored in the results directory. Log
files generated by Stata are stored in the log directory.


7. NOTES

- All results are deterministic.
- Any random number generation uses fixed seeds set within the code.
- The replication package has been tested under the computational
  environments described above.

==============================================================================

